package com.example.suota.suota.receiver;

import android.bluetooth.BluetoothAdapter;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

/**
 * Created by MOSL
 * Date: 2023/12/19
 **/
public class BleSwitchReceiver extends BroadcastReceiver {

    private OnSwitchChange switchChange;

    public interface OnSwitchChange{
        void change(int state);
    }

    public void setSwitchChange(OnSwitchChange switchChange) {
        this.switchChange = switchChange;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE,BluetoothAdapter.ERROR);
        if (switchChange != null){
            switchChange.change(state);
        }
    }
}
